package pers.cz.model;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @program: PostGirl-panent
 * @description: 验证码信息
 * @author: Cheng Zhi
 * @create: 2022-06-20 09:40
 **/
public class CaptchaImage implements Serializable {

    //验证码
    private String code;
    //过期时间
    private LocalDateTime expireTime;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public LocalDateTime getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(LocalDateTime expireTime) {
        this.expireTime = expireTime;
    }

    /*初始化文字与 过期时间（秒）*/
    public CaptchaImage(String code, int expireAfterSeconds) {
        this.code = code;
        this.expireTime = LocalDateTime.now().plusSeconds(expireAfterSeconds);
    }
    /*判断是否过期*/
    public boolean isExpired(){
        return LocalDateTime.now().isAfter(expireTime);
    }
}
